package com.zzq.my.jetpacks.jectpackapp.ui.fragment

import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import by.kirich1409.viewbindingdelegate.viewBinding
import com.aisier.architecture.base.BaseFragment
import com.zzq.my.jetpacks.jectpackapp.*
import com.zzq.my.jetpacks.jectpackapp.databinding.FragmentFourBinding
import com.zzq.my.jetpacks.util.loadFragments
import com.zzq.my.jetpacks.util.showHideFragment

/**
 * 描述：class describe
 * 作者：zhuangzeqin
 * 时间: 2021/12/27-17:57
 * 邮箱：zzq@eeepay.cn
 * 备注:
 */
class FourFragment : BaseFragment(R.layout.fragment_four), View.OnClickListener {
    private val bindView by viewBinding(FragmentFourBinding::bind)
    private lateinit var fragmentsMap: Map<String, Fragment>

    companion object {
        fun newInstance() = FourFragment()
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        bindView.btn1.setOnClickListener(this)
        bindView.btn2.setOnClickListener(this)
        bindView.btn3.setOnClickListener(this)
        fragmentsMap = generate123Fragments()
        loadFragments(R.id.fl_container,0,*fragmentsMap.values.toTypedArray())

    }

    override fun lazyInit() {

    }

    override fun onClick(view: View) {
        when (view.id) {
            bindView.btn1.id -> {
                showHideFragment(fragmentsMap.getValue(FRAGMENT_ONE))
            }
            bindView.btn2.id -> {
                showHideFragment(fragmentsMap.getValue(FRAGMENT_TWO))
            }
            bindView.btn3.id -> {
                showHideFragment(fragmentsMap.getValue(FRAGMENT_THREE))
            }
        }


    }
}